<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 定义一个v-fbind指令，和v-bind功能类似，可以让其绑定的元素默认获取焦点-->
    <div id="app">
        <h2>v-fbind绑定的值：<input type="text" v-fbind="n"></h2>
        <h2>v-bind绑定的值：<input type="text" :value="n"></h2>
        <button @click="n++">点我n+1</button>
    </div>

    <script src="../JS/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    n: 10
                }
            },
            directives: {
                fbind: {
                    bind(element,binding) {
                        element.value = binding.value
                        console.log('bind');
                    },
                    inserted(element,binding) {
                        console.log('inserted');
                        element.focus()
                    },
                    update(element,binding) {
                        console.log('updare');
                        element.value = binding.value
                        element.focus()
                    }
                },


            }

        })
    </script>
</body>

</html>